#include <stdio.h>

void insertion(int value[], int count)
{
	int temp;
	for(int i=0; i<count; i++)
	{
		temp = value[i];
		int num = i;
		while( num>0 && value[num-1]>temp)
		{
			value[num] = value[num-1];
			num -= 1;
		}
		value[num] = temp;
		if(i>0 && i<7)
		{
			printf("Step-%d, ",i);
			for(int j=0; j<count; j++)
			{
				printf("%d ",value[j]);
			}
			printf("\n");
		}
	}

}

int main(void)
{
	int arry[8] = { 80, 50, 7, 10, 60, 2, 40, 30};

	printf("Before Sort : ");
	for(int i=0; i<8; i++)
	{
		printf("%d ",arry[i]);
	}
	printf("\n");

	insertion(arry, 8);

	printf("After Sort : ");
	for(int i=0; i<8; i++)
	{
		printf("%d ", arry[i]);
	}
}